---
title: BM25 Scoring
---

<Note>
The `rank_bm25` function has been deprecated as of 0.8.5 and has been replaced with `score_bm25`, which follows new query syntax and has a different return type.
</Note>

## Overview

BM25 scores measure how relevant a score is for a given query. Higher scores indicate higher relevance.

## Basic Usage

The `score_bm25` function takes a query and returns a table with two columns: the `key_field` of each result and its BM25 score. `score_bm25` accepts the same
parameters as [`search`](/search/full-text/bm25).

```sql
SELECT * FROM <index_name>.score_bm25('<query>');
```

<Accordion title="Example Usage">

```sql
SELECT * FROM search_idx.score_bm25(
	'description:keyboard',
	limit_rows => 10
);
```

</Accordion>

<ParamField body="index_name" required>
  The name of the index.
</ParamField>
<ParamField body="query" required>
  The query string.
</ParamField>
<ParamField body="limit_rows">The maximum number of rows to return.</ParamField>
<ParamField body="offset_rows">
  The number of rows to skip before starting to return rows.
</ParamField>
<ParamField body="stable_sort" default={false}>
  A boolean specifying whether ParadeDB should stabilize the order of
  equally-scored results, at the cost of performance.
</ParamField>


## Joining BM25 Scores

Because `score_bm25` generates a new `score_bm25` column, the function does not return all the columns of the original table.
To map the columns of the original table to the output of `score_bm25`, perform a JOIN on the `key_field` column.

```sql
-- Here, the key_field is "id"
WITH scores AS (
    SELECT * FROM search_idx.score_bm25(
      'description:keyboard',
      highlight_field => 'description'
    )
)
SELECT scores.id, description, score_bm25
FROM scores
LEFT JOIN mock_items ON scores.id = mock_items.id;
```

<Accordion title="Expected Output">
```csv
 id |       description        | score_bm25
----+--------------------------+------------
  2 | Plastic Keyboard         |  3.2668595
  1 | Ergonomic metal keyboard |  2.8213787
(2 rows)
```
</Accordion>
